package com.itbaizhan;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.InputStream;
import java.sql.Connection;
import java.util.Properties;

public class DruidTest {
    public static void main(String[] args) throws Exception {
        //获取读取druid配置的字节输入流
        InputStream is = DruidTest.class.getClassLoader().getResourceAsStream("druid.properties");
        //创建Properties对象
        Properties pos = new Properties();
        //加载配置文件
        pos.load(is);
        //获取连接池对象
        DataSource ds = DruidDataSourceFactory.createDataSource(pos);

        //获取连接
        Connection connection = ds.getConnection();
        System.out.println(connection);
    }
}
